package com.code.p9.代理模式.静态代理;

import com.code.p9.代理模式.动态代理.Subject;

import java.lang.reflect.InvocationHandler;

/**
 * 描述: 具体业务的动态代理
 *
 * @author CodeYang_Site
 * @version 2021/6/7 1:08
 */
public class SubjectDynamicProxy extends DynamicProxy {


    public static <T> T newProxyInstance(Subject subject) {
        //获得ClassLoader
        ClassLoader loader = subject.getClass().getClassLoader();
        //获得接口数组
        Class<?>[] classes = subject.getClass().getInterfaces();
        //获得handler
        InvocationHandler handler = new MyInvocationHandler(subject);
        return newProxyInstance(loader, classes, handler);
    }
}
